<?php
/*
    Copyright (C) 2008 - 2010 Inanta Martsanto
    
    This file is part of Koma.

    Koma is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Koma is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Koma.  If not, see <http://www.gnu.org/licenses/>.
    
    Inanta Martsanto (inanta@inationsoft.com)
*/

class KomaContainerForm extends KomaPanel
{
	function __construct($name = 'form', $action = KOMA_URL, $method = 'post')
	//function __construct($accept = null, $acceptcharset = 'UTF-8', $action = KOMA_URL, $enctype = 'application/x-www-form-urlencoded', $method = 'post', $name = 'form')
	{
                $this->createProperties(array('Accept' => $accept,
					      'AcceptCharset' => $acceptcharset,
					      'Action' => $action,
					      'Elements' => array(),
                                              'Enctype' => $enctype,
                                              'Method' => $method,
					      'Name' => $name
                                              ));

		parent::__construct(__CLASS__);
                
                $this->OpenTag = '<form '. (isset($this->Accept) ? 'accept="'.$this->Accept.'" ' : '') . (isset($this->AcceptCharset) ? 'accept-charset="'.$this->AcceptCharset.'" ' : '') .'action="'.$this->Action.'" enctype="'.$this->Enctype.'" method="'.$this->Method.'" name="'.$this->Name.'" id="'.$this->Name.'">';
                $this->CloseTag = '</form>';
                
                //KomaScriptManager::getInstance()->addScript('$(document).ready(function() { $("#testform").validate('.KomaValidatorManager::getInstance()->getValidator().'); });');
                //KomaScriptManager::getInstance()->addScript('$(document).ready(function() { $("#testform").validate(); });');
                
	}
        
        function __toString()
        {
                KomaScriptManager::getInstance()->addScript('$(document).ready(function() { $("#'.$this->Name.'").validate('.KomaValidatorManager::getInstance()->getValidator().'); });');
                return parent::__toString();
        }
}

?>